﻿cmake_minimum_required (VERSION 3.26)

# INCLUDE 3RD PARTY LIBRARIES
include("${CMAKE_SOURCE_DIR}/Scripts/FetchLibraries.cmake")
FetchContent_MakeAvailable(glfw)
FetchContent_MakeAvailable(stbi)
FetchContent_MakeAvailable(assimp)

file(GLOB_RECURSE SUBDIRECTORIES "${CMAKE_SOURCE_DIR}/Source/Runtime/*.h"  "${CMAKE_SOURCE_DIR}/Source/Runtime/*.cpp" )
source_group("Runtime" "${CMAKE_SOURCE_DIR}/Source/Runtime" $"{SUBDIRECTORIES}")
add_library ("Runtime" STATIC main.cpp ${SUBDIRECTORIES} "Application/Application.h" "Application/Application.cpp" "Window/WindowManager.h" "Application/ApplicationManager.h" "World/ObjectPipeline.h" "World/ObjectPipeline.cpp" "World/Camera.h" "World/Camera.cpp" "World/GameObject.h" "World/GameObject.cpp" "World/CameraManager.h" "World/Light.h" "World/Light.cpp")

target_include_directories("Runtime" PRIVATE "${CMAKE_SOURCE_DIR}/Source")

if (stbi_POPULATED)
	target_include_directories("Runtime" PUBLIC "${stbi_SOURCE_DIR}")
	target_compile_definitions("Runtime" PUBLIC STB_IMAGE_IMPLEMENTATION=1)
endif()


target_link_libraries("Runtime" PUBLIC glfw)
target_link_libraries("Runtime" PUBLIC assimp)
target_link_libraries("Runtime" PUBLIC d3d11.lib)
target_link_libraries("Runtime" PUBLIC dxgi.lib)
target_link_libraries("Runtime" PUBLIC d3dcompiler.lib)
target_link_libraries("Runtime" PUBLIC dxguid.lib)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
	target_compile_definitions("Runtime" PUBLIC TUTORIAL_DEBUG)
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
	target_compile_definitions("Runtime" PUBLIC TUTORIAL_RELEASE)
endif()

# MACRO DEFINITIONS
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
	target_compile_definitions("Runtime" PUBLIC RUNTIME_API=__declspec\(dllexport\))
	target_compile_definitions("Runtime" PUBLIC FORCEINLINE=_forceinline)
else()
	message(FATAL_ERROR "Unsupported Compiler")
endif()

add_compile_definitions("SHADER_ROOT=${CMAKE_SOURCE_DIR}/Shaders/")

